package com.example.demo.mapper;

import com.example.demo.entity.Account;
import com.example.demo.entity.Company;
import org.apache.ibatis.annotations.*;

import java.awt.*;
import java.util.List;

@Mapper
public interface AccountMapper {
    // 创建账户
    @Insert("INSERT INTO account(username, password) VALUES(#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int createAccount(Account account);

    // 根据ID删除账户
    @Delete("DELETE FROM account WHERE id = #{id}")
    int deleteAccount(Integer id);

    // 根据用户名查找账户
    @Select("SELECT * FROM account WHERE username = #{username}")
    Account findAccountByUsername(String username);

    // 根据ID查找账户
    @Select("SELECT * FROM account WHERE id = #{id}")
    Account findAccountById(Integer id);

    // 更新账户信息
    @Update("UPDATE account SET username = #{username}, password = #{password} WHERE id = #{id}")
    int updateAccount(Account account);

    // 查询所有账户
    @Select("SELECT * FROM account")
    List<Account> findAllAccounts();
}